﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager:Singleton<GameManager>
{
    // [NonSerializedAttribute] public Text text_cherry_mark;
    [SerializeField] private float _myscore = 0.0f;
    Transform _my_player;

    Dictionary<string,object> _ui_dic = new Dictionary<string, object>();

    Text _ui_mark_display;

    new void Awake()
    {
        base.Awake();
        App.gameManager = Instance;
    }

    public void AddUiMapping(string key,object ui)
    {
        _ui_dic.Add(key,ui);
    }

    public object GetUiByKey(string key)
    {
        object ret = null;
        if(_ui_dic.TryGetValue(key,out object _ret)){
            ret = _ret;
        }

        return ret;
    }
    public void AddScore(float score)
    {
        _myscore += score;
        if(ReferenceEquals(_ui_mark_display,null))
        {
            _ui_mark_display = (Text)GetUiByKey("LabelCherryMark");
        }

        if(!ReferenceEquals(_ui_mark_display,null))
        {
            _ui_mark_display.text = "分数：" + _myscore;
        }
    }
    public void SetPlayer(Transform player)
    {
        _my_player = player;
    }

    public Transform GetPlayer()
    {
        return _my_player;
    }

    public bool IsEmeny(string tag)
    {
        if(Enum.Tag.Frog == tag){
            return true;
        }

        return false;
    }
}
